<?php
	include "public/commom/config.php";//引入配置连接数据库文件
	
	if(isset($_SESSION["user_id"])) {//是否登录
		//已登录
		if($_POST) {
			$content = $_POST["content"];//评论内容
			$privacy = $_POST["privacy"];//评论隐私
			$time = time();//时间戳
			$user_id = $_SESSION["user_id"];//用户id
			$weibo_id = $_POST["weibo_id"];//微博id
			
			$sql = "INSERT INTO comment (content, privacy, time, user_id, weibo_id) VALUES ('$content', '$privacy', '$time', '$user_id', '$weibo_id')";//sql语句  - 发布评论
			
			$result = mysqli_query($conn, $sql);//result - 执行sql语句
			
			mysqli_close($conn);//关闭数据库连接
		
			echo "<script>location.href='" . $_SERVER["HTTP_REFERER"] . "';</script>";//返回上一页
		}
	}else {
		//未登录
		echo "您还未登录,请登录账户。";
	}
?>